package com.heima.comment.controller;

import com.heima.comment.dtos.CommentRepayDto;
import com.heima.comment.dtos.CommentRepayLikeDto;
import com.heima.comment.dtos.CommentRepayListDto;
import com.heima.comment.service.CommentRepayService;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author DiXiaoNie
 * @since 2023/1/5 19:00
 */
@RestController
@RequestMapping("/api/v1/comment_repay")
public class CommentRepayController {

    @Autowired
    private CommentRepayService commentRepayService;

    /**
     * 发送评论回复
     *
     * @param dto dto
     * @return {@link ResponseResult }
     * @author DiXiaoNie
     * @date 2023/01/05
     */
    @PostMapping("/save")
    public ResponseResult save(@RequestBody CommentRepayDto dto) {
        return this.commentRepayService.save(dto);
    }


    /**
     * 回显评论回复
     *
     * @param dto dto
     * @return {@link ResponseResult }
     * @author DiXiaoNie
     * @date 2023/01/05
     */
    @PostMapping("/load")
    public ResponseResult load(@RequestBody CommentRepayListDto dto) {
        return this.commentRepayService.load(dto);
    }


    /**
     * 回复评论点赞
     *
     * @param dto dto
     * @return {@link ResponseResult }
     * @author DiXiaoNie
     * @date 2023/01/05
     */
    @PostMapping("/like")
    public ResponseResult like(@RequestBody CommentRepayLikeDto dto) {
        return this.commentRepayService.like(dto);
    }
}
